<tr>
    <?php if ($admin): ?><td class="name"><?php echo $user->fullName ?></td><?php endif ?>
    <?php $i = $duration = 0; ?>
    
    <?php foreach ($requests as $request): ?>
        <?php $daysBeforeRequest = get_days_before_request($calendar, $i, $request) + 1 ?>
        <?php $i += $daysBeforeRequest ?>
        <?php $requestDuration = get_displayed_duration($calendar, $i, $request) + 1; ?>
        <?php $i += $requestDuration ?>

        <?php echo str_repeat('<td></td>', $daysBeforeRequest) ?>

        <td id="<?php echo "req-".$request->id ?>" colspan="<?php echo $requestDuration; ?>" class="request <?php
            echo $request->status. " ".$request->typeId;
            echo starts_before($calendar, $request) ? " starts-before" : "";
            echo ends_after($calendar, $request) ? " ends-after" : ""; ?>">
            <?php if ($admin): ?>
                <a href="<?php echo url_for('requests/validate?id='.$request->id.'&userId='.$user->id) ?>" class="fancybox-ajax" title="<?php echo $requestTypes[$request->typeId] ?>"></a>
            <?php else: ?>
                <a href="<?php echo url_for('requests/edit?id='.$request->id) ?>"></a>
            <?php endif ?>
        </td>
    <?php endforeach ?>

    <?php $daysAfterRequests = count($calendar) - $i ?>
    <?php echo str_repeat('<td></td>', ($daysAfterRequests >= 0) ? $daysAfterRequests : 0) ?>
</tr>